<?php

class Events {

	public static function On($namespace, $event, $function) {
		if (!is_callable($function)) {
			return false;
		}

		if (version_compare(PHP_VERSION, '5.3.0') === 1 && $function instanceof Closure) {
			
		}
	}

}

class Event {

	private $_name;
	private $_listeners = array();

	public function __construct($name) {
		$this->_name = $name;
	}

	public function Subscribe($function) {
		if (is_callable($function)) {
			$this->_listeners[] = $function;
		}
	}

	public function Fire() {
		$args = func_get_args();
		foreach ($this->_listeners as $function) {
			try {
				@call_user_func_array($function, $args);
			} catch (Exception $ex) {}
		}
	}

	public function PurgeListeners() {
		$this->_listeners = array();
	}

}
